<?php
foreach ($this->taskView->tasks as $task):
    $timestamp = $task->signal->date->format("U");
    $status = $task->status;
    $completeText = "";
    $completeAction = "Mark Complete";
    $user1 = User::withId($task->taskUserId);
    $user2 = User::withId($task->taskAssignedTo);
    $message = $task->signal->message;
    $dateCreated = $task->taskDateCreated;
    $stream = Stream::withId(base64_encode($task->signal->streamID));
    $item = $message->getItems();
    $message = $item[0];
    $date = new DateTime($message->getTime());
    $timestamp = $date->format("U");
    if ($status == 2) {
        $completeText = "completed";
        $completeAction = "Undo Complete";
    }
    ?>
    <li id="<?php echo $task->taskId; ?>">
        <div class="mozaic-widget item-285541 widget-mention_signal" data-guid="widget-183" data-id="285541" data-initialized="true" data-params="{&quot;isLoadedLater&quot;:false,&quot;id&quot;:285541,&quot;channels&quot;:{&quot;/signals&quot;:&quot;/tasks_annotables-154&quot;,&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;,&quot;/streams&quot;:&quot;GLOBAL/streams&quot;,&quot;/tags&quot;:&quot;GLOBAL/tags&quot;,&quot;/social_profiles&quot;:&quot;GLOBAL/social_profiles&quot;,&quot;/users&quot;:&quot;GLOBAL/users&quot;,&quot;/filters&quot;:&quot;/filters-4&quot;}}" data-widget="mention_signal" data-wrapped="true">
            <!--start template: templates/mention/signals/mention.hjs -->

            <div class="mention-container alert-container signals-mention main-mention signal-orange" id="mention-">
                <div class="mention-left-content">
                    <div class="annotable-extra-container">
                        <div class="mozaic-widget widget-signal_annotable_extra" data-guid="widget-190" data-initialized="true" data-params="{&quot;channels&quot;:{&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;,&quot;/filters&quot;:&quot;/filters-4&quot;,&quot;/streams&quot;:&quot;/streams-2&quot;},&quot;id&quot;:285541}" data-widget="signal_annotable_extra">
                            <!--start template: templates/annotable/annotable_extra.hjs -->

                            <p class="mention-time-stamp extend signals-time-stamp-2" data-timestamp="<?php echo $timestamp; ?>" data-timestamp-format="timeago"><?php echo Utils::humanTiming($date->format("U")); ?></p>

                            <p class="mention-type"><a class="platform-link action-color-active" data-value="" rel="tooltip" title="Show all mentions">mention</a></p>

                            <p class="mention-type additional-timestamp" data-timestamp="<?php echo $timestamp; ?>" data-timestamp-format="MMM D YYYY h:mm A"><?php echo $message->getTime() ?></p>
                        </div>
                    </div>

                    <div class="mention-circle-holder">
                        <i class="icon-cirlce-background"></i>

                        <!--<div class="icon-circle-mention background-icon icon-circle-2">
                             <i class="icon-signals-engage"></i> 
                        </div>-->
                    </div>
                </div>

                <div class="mention-right-content">
                    <div class="mention-right-wrapper">
                        <div class="mention-right-container extend">
                            <div class="mention-content">
                                <div class="mozaic-widget widget-signal_top_bar" data-guid="widget-191" data-initialized="true" data-params="{&quot;channels&quot;:{&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;,&quot;/streams&quot;:&quot;/streams-2&quot;,&quot;/filters&quot;:&quot;/filters-4&quot;},&quot;id&quot;:285541}" data-widget="signal_top_bar">
                                    <!--start template: templates/mention/signals/signal_top_bar.hjs -->

                                    <div class="mention-top-bar">
                                        <p class="mention-type signal-type"><a class="filter-link filter-link-signal-type" data-filter="type__in" data-value="mention" href="#stream/<?php echo base64_encode($task->signal->streamID) ?>" rel="tooltip" title="Show all Mention Signals">Mention</a> <span class="signal-type-span">for</span> <a class="filter-link filter-link-stream" data-filter="keyword_id" data-value="1000031973" href="#stream/<?php echo base64_encode($task->signal->streamID) ?>" rel="tooltip" title="Show all <?php echo $stream->name; ?> Signals"><i class="icon-stream-market_terms-small"></i><?php echo $stream->name; ?><span class="signal-stream-visual"></span></a></p>

                                        <p class="mention-type additional-timestamp signals-additional-time" data-timestamp="<?php echo $timestamp; ?>" data-timestamp-format="MMM D YYYY h:mm A"><?php echo $date->format("M d Y h:m A P") ?></p>
                                    </div><!-- end template: templates/mention/signals/signal_top_bar.hjs -->
                                </div>

                                <div class="mention-core">
                                    <div class="mention-core-wrapper">
                                        <div class="mention-author-image" style="float:left; margin:0;"></div>

                                        <div class="mention-content-full">
                                            <div class="timeline-content-tweak">
                                                <p class="author-name"><a class="action-color-hover" href="<?php echo $message->getURL(); ?>" target="_blank"><?php echo $message->getThreadTitle(); ?></a></p><span class="mention-display-name"><?php echo $message->author ?></span>
                                            </div>
                                            <a class="btn-source" href="<?php echo $message->getURL(); ?>" target="_blank">
                                                <i class="icon-action-viewsource action-color-normal"></i>
                                            </a>

                                            <p class="mention-text original-mention"><?php
                                            $text = $message->getText();
                                            if (substr_count($text, " ") > 100) {
                                                //find the 100th char(' ')
                                                $endpos = 200;
                                                $endpos = strpos($text, " ", $endpos);
                                                echo Signal::parseLinks(substr($text, 0, $endpos));
                                                ?>
                                                <span class="readmore-threedot">...</span>
                                                <span class="readmore spanshow" onclick="expand(this);" style="color: orange; cursor: pointer;">Read more</span>
                                                <span class="readmore-content hide"><?php echo Signal::parseLinks(substr($text, $endpos)); ?></span>
                                                <?php
                                            }
                                            else
                                                echo Signal::parseLinks($text);
                                            ?></p>
                                        </div>
                                    </div>
                                </div>

                                <div class="tags-holder-container first-two-tags">
                                    <div class="mozaic-widget widget-annotable_tags" data-guid="widget-192" data-initialized="true" data-params="{&quot;base_id&quot;:285541,&quot;channels&quot;:{&quot;/taggings&quot;:&quot;/taggings-187&quot;,&quot;/tags&quot;:&quot;/tags-3&quot;,&quot;/filters&quot;:&quot;/filters-4&quot;,&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;}}" data-widget="annotable_tags">
                                        <!--start template: templates/annotable/annotable_tags.hjs -->

                                        <div class="clear"></div><!-- end template: templates/annotable/annotable_tags.hjs -->
                                    </div>
                                </div>

                                <div class="more-tags-holder">
                                    <i class="icon-tags"></i>

                                    <div class="more-tags-tooltip">
                                        <div class="arrow-icon"></div>

                                        <div class="tags-holder-container more-tags-container">
                                            <div class="mozaic-widget widget-annotable_tags" data-guid="widget-193" data-initialized="true" data-params="{&quot;base_id&quot;:285541,&quot;channels&quot;:{&quot;/taggings&quot;:&quot;/taggings-187&quot;,&quot;/tags&quot;:&quot;/tags-3&quot;,&quot;/filters&quot;:&quot;/filters-4&quot;,&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;}}" data-widget="annotable_tags">
                                                <!--start template: templates/annotable/annotable_tags.hjs -->

                                                <div class="clear"></div><!-- end template: templates/annotable/annotable_tags.hjs -->
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="signal-action-bar-container">
                                    <div class="mozaic-widget widget-signal_action_bar" data-guid="widget-194" data-initialized="true" data-params="{&quot;action&quot;:&quot;Engage&quot;,&quot;context_type&quot;:&quot;market_terms&quot;,&quot;type&quot;:&quot;mention&quot;,&quot;generator&quot;:&quot;twitter&quot;,&quot;channels&quot;:{&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;,&quot;/social_profiles&quot;:&quot;/social_profiles-5&quot;,&quot;/streams&quot;:&quot;/streams-2&quot;},&quot;id&quot;:285541,&quot;stream_id&quot;:&quot;1000031973&quot;,&quot;stream_name&quot;:&quot;Soccer&quot;}" data-widget="signal_action_bar">
                                        <!--start template: templates/mention/signals/signal_action_bar.hjs -->

                                        <div class="signal-review-bar">
                                            <p>Retweet or Reply</p>
                                        </div>

                                        <ul class="mention-action-bar">
                                            <!--                                            <li class="mention-action-button retweet_dropdown">
                                                                                            <div class="btn-group dropdown">
                                                                                                <button class="btn btn-danger retweet dropdown-toggle action-color-background" data-platform-id="" data-toggle="dropdown"><i class="icon-action-retweet"></i>
                                            
                                                                                                    <div>
                                                                                                        Retweet
                                                                                                    </div><i class="icon-action-dropdown"></i></button>
                                            
                                                                                                <div class="tag-mention">
                                                                                                    <span class="square-hack"></span>
                                            
                                                                                                    <div class="dropdown-menu">
                                                                                                        <ul class="overview">
                                                                                                            <li>
                                                                                                                <a class="retweet_this" data-action="retweet" data-platform-id=""><i class="icon-circle-list"></i>Retweet</a>
                                                                                                            </li>
                                            
                                                                                                            <li>
                                                                                                                <a class="retweet_this" data-action="quote" data-platform-id=""><i class="icon-circle-list"></i>Quote</a>
                                                                                                            </li>
                                                                                                        </ul>
                                                                                                    </div>
                                                                                                </div>
                                                                                            </div>
                                                                                        </li>
                                            
                                                                                        <li class="mention-action-button"><button class="btn btn-danger reply" data-action="reply"><i class="icon-action-reply"></i>
                                            
                                                                                                <div>
                                                                                                    Reply
                                                                                                </div></button></li>
                                            -->
                                            <li class="mention-action-button mention-actions mention-tag">
                                                <div class="btn-group">
                                                    <button data-toggle="dropdown" class="btn btn-danger"><i class="icon-action-tag"></i><div><font><font>Tag</font></font></div><i class="icon-action-dropdown"></i></button>
                                                    <div class="mozaic-widget tag_mention widget-tag_annotable" data-widget="tag_annotable" data-params="{&quot;object_class&quot;:&quot;signal_influencer&quot;,&quot;channels&quot;:{&quot;/tags&quot;:&quot;/tags-3&quot;,&quot;/taggings&quot;:&quot;/taggings-1501&quot;,&quot;/annotables&quot;:&quot;/signals-1414&quot;},&quot;id&quot;:&quot;27852612&quot;}" data-guid="widget-1802" data-initialized="true"><!--start template: templates/tag_annotable.hjs -->
                                                        <span class="square-hack"></span>
                                                        <div class="dropdown-menu">
                                                            <ul class="overview" messageid="<?php echo $message->getId() ?>" steamId="<?php echo $task->signal->streamID; ?>">
                                                                <?php
                                                                $tags = Tag::getList();
                                                                foreach ($tags as $tag) {
                                                                    echo "<li data-id=\"$tag->tagId\">
                                                                            <a><i class=\"icon-circle-list\"></i><font><font>$tag->tagName</font></font></a>
                                                                        </li>";
                                                                }
                                                                ?>
                                                                <li><a><i class="icon-plus"></i><font><font>Add new tag</font></font></a></li>
                                                            </ul>
                                                        </div>
                                                        <!-- end template: templates/tag_annotable.hjs --></div>
                                                </div>
                                            </li>

                                            <li class="mention-action-button"><button class="btn btn-danger add-task" messageid="<?php echo $task->signal->messageId; ?>" streamid="<?php echo $task->signal->streamID; ?>"><i class="icon-action-addtask"></i>

                                                    <div>
                                                        <em>Add&nbsp;</em>task
                                                    </div></button></li>


                                            <li class="mention-action-button">
                                                <div class="btn-group settings-stream-menu">
                                                    <button class="btn dropdown-toggle" data-toggle="dropdown"><i class="icon-settings"></i><i class="icon-action-dropdown"></i></button> <span class="square-hack"></span>

                                                    <div class="dropdown-menu pull-right">
                                                        <ul class="signal-preferences-dropdown">
                                                            <li class="mention-action-button customize-signals-button" data-id="285541">
                                                                <a class="action-color-hover"><i class="icon-settings"></i>Customize Signals for this Stream</a>
                                                            </li>

                                                            <li class="mention-action-button disable-signals-button" data-id="285541">
                                                                <a class="action-color-hover"><i class="icon-minus-sign"></i>Disable Signals for this Stream</a>
                                                            </li>

                                                            <li class="mention-action-button mark-irrelevant-button" data-id="285541">
                                                                <a class="action-color-hover"><i class="icon-action-irrelevant"></i>Mark Signal as Irrelevant</a>
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </li>

                                            <li class="mention-action-button go-top-button"><button class="btn btn-danger"><i class="icon-go-top"></i></button></li>
                                            <div class="tags-holder-container">
                                                    <?php
                                                        $_tags = Tag::getTag($task->signal->signalID);
                                                        foreach($_tags as $tag) {
                                                            echo "<div class=\"tag-holder-container\"><label>$tag->tagName</label></div>";
                                                        }
                                                    ?>
                                            </div>
                                        </ul><!-- end template: templates/mention/signals/signal_action_bar.hjs -->
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="annotables-replies-content">
                            <div class="annotations-holder-container">
                                <div class="mozaic-widget widget-annotable_tasks_and_posts" data-guid="widget-195" data-initialized="true" data-params="{&quot;base_id&quot;:285541,&quot;channels&quot;:{&quot;/tasks&quot;:&quot;/tasks-188&quot;,&quot;/posts&quot;:&quot;/social_posts-189&quot;,&quot;/social_profiles&quot;:&quot;/social_profiles-5&quot;,&quot;/users&quot;:&quot;/users-0&quot;,&quot;/annotables&quot;:&quot;/tasks_annotables-154&quot;,&quot;/streams&quot;:&quot;/streams-2&quot;}}" data-widget="annotable_tasks_and_posts">
                                    <!--start template: templates/annotable/annotable_tasks_and_posts.hjs -->

                                    <div class="tasks-and-posts">
                                        <div class="annotable-tasks-and-posts">
                                            <div class="mozaic-widget task-14349 first_overall last_overall first last widget-task" data-guid="widget-219" data-initialized="true" data-params="{&quot;id&quot;:14349,&quot;channels&quot;:{&quot;/tasks&quot;:&quot;/tasks-188&quot;,&quot;/users&quot;:&quot;/users-0&quot;}}" data-widget="task">
                                                <!--start template: templates/tasks/task.hjs -->

                                                <div class="mention-container stream-task-container <?php echo $completeText ?>">
                                                    <div class="mention-right-content">
                                                        <div class="mention-right-wrapper">
                                                            <div class="mention-right-container">
                                                                <div class="mention-content">
                                                                    <div class="user-author-mention-actions mention-top-bar">
                                                                        <div class="float-left">
                                                                            <img src="Images/avatar.png">

                                                                            <p><strong><?php echo $user1->name ?></strong> <span>assigned a task to</span></p>
                                                                        </div>

                                                                        <div class="float-left">
                                                                            <img src="Images/avatar.png">

                                                                            <p><strong><?php echo $user2->name ?></strong></p>
                                                                        </div><span class="task-posted-time" data-timestamp="<<?php echo $timestamp ?>" data-timestamp-format="MMM D YYYY h:mm A"><?php echo $dateCreated->format("M d Y h:m A P") ?></span>
                                                                    </div>

                                                                    <div class="mention-core task-core">
                                                                        <div class="mention-core-wrapper">
                                                                            <div class="mention-author-image">
                                                                                <div class="complete-task-button">
                                                                                    <div class="complete-task-img mark-complete">
                                                                                        <i class="icon-complete-task-big"></i>
                                                                                    </div>

                                                                                    <p><?php echo strtoupper($completeText); ?></p>
                                                                                </div>
                                                                            </div>

                                                                            <div class="mention-content-full">
                                                                                <p class="author-name"><?php echo $task->taskName; ?></p>

                                                                                <p class="mention-text"><?php
                                                                                    if ($completeText)
                                                                                        echo ucfirst($completeText) . ": ";
                                                                                    echo $task->taskContent;
                                                                                    ?></p>
                                                                            </div>
                                                                        </div>

                                                                        <ul class="mention-action-bar">
                                                                            <li class="mention-action-button"><button class="mark-complete btn btn-danger" taskId="<?php echo $task->taskId; ?>"><i class="icon-complete-task"></i> <?php echo $completeAction; ?></button></li>

                                                                            <li class="mention-action-button discard-button"><button class="delete-task btn btn-danger" data-id="14349" taskId="<?php echo $task->taskId; ?>"><i class="icon-action-delete"></i></button></li>
                                                                        </ul>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div><!-- end template: templates/tasks/task.hjs -->
                                            </div>
                                        </div>

                                        <div class="clear"></div>
                                    </div><!-- end template: templates/annotable/annotable_tasks_and_posts.hjs -->
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="clear"></div>
                </div>

                <div class="clear"></div>
            </div><!-- end template: templates/mention/signals/mention.hjs -->
        </div>
    </li>
<?php endforeach; ?>